package com.gcu.service.impl;

import com.gcu.Mapper.loginMapper;

import com.gcu.pojo.loginInfo;
import com.gcu.service.loginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class loginServiceImpl implements loginService {

    @Autowired
    private loginMapper lomapper;

    @Override
    public List<loginInfo> selectAllLoginInfo() {
        List<loginInfo> list = lomapper.selectLoginInfo();
        return list;
    }

    @Override //通过账号获取密码信息判断是否存在用户
    public boolean login(loginInfo lo) {
        String userid = lo.getUserid();
        loginInfo userloginInfo = lomapper.selectAllByUserid(userid);
//        System.out.println(userloginInfo.toString());
//        System.out.println("lo.getpassword"+lo.getPassword());
        if (userloginInfo != null && lo.getPassword().equals(userloginInfo.getPassword())){
            return true;
        }
        return false;
    }

    @Override
    public int register(loginInfo loginfo) {
        return lomapper.insert(loginfo);
    }
}
